package com.cjm.algorithm.leetcode;

import java.util.HashMap;
import java.util.Map;

public class ToHe {
    public static int[] twoHe(int[] nums, int target) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            int key = target - num;
            Integer integer = map.get(key);
            if (integer != null) {
                return new int[]{integer, i};
            }
            map.put(num, i);
        }
        return null;
    }

    public static void main(String[] args) {
        int[] ints = twoHe(new int[]{2, 7, 11, 15}, 9);
        System.err.println("OK");
    }
}
